TEST_HOME = $(shell pwd)
CC :=gcc
CXX :=g++
LD := $(CXX)
CFLAGS  = -O2 -Wall
LDFLAGS = -O2

WORK_DIR  = $(shell pwd)
BUILD_DIR = $(WORK_DIR)/build
SRC_DIR = $(WORK_DIR)/src
INC_PATH := $(WORK_DIR)/include $(INC_PATH)
OBJ_DIR  = $(BUILD_DIR)/obj
INCLUDES = $(addprefix -I, $(INC_PATH))

CFLAGS += $(INCLUDES)

SRCS += $(wildcard $(SRC_DIR)/*.c)
SRCS += $(wildcard $(SRC_DIR)/component/*.c)

OBJS := $(patsubst $(SRC_DIR)/%.c,$(OBJ_DIR)/%.o,$(SRCS))

BINARY := $(BUILD_DIR)/myprogram


$(OBJ_DIR)/%.o:$(SRC_DIR)/%.c
	@echo + CC $<
	@mkdir -p $(dir $@)
	@$(CC) $(CFLAGS) -c -o $@ $<

$(BINARY):$(OBJS)
	@echo + LD $@
	@$(LD) -o $@  $(OBJS) $(LDFLAGS) 

all: $(BINARY)
	@$(BINARY)

t:
	@echo $(OBJ_DIR)
	@echo $(SRC_DIR)
	

.PHONY: all clean

	
clean:
	rm -rf $(BUILD_DIR)